/**
 * 
 */
package com.cqan.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.cqan.core.dao.IEntityDao;
import com.cqan.core.exception.BasicException;
import com.cqan.core.pojo.DomainObject;

/**
 * @author wuhui
 *
 * 下午03:52:12
 */
public abstract class EntityDaoImpl extends BaseDaoImpl  implements IEntityDao {

	
	 @SuppressWarnings("unchecked")
	    public <T extends DomainObject> Map<Long, T> getTsByIds(Long[] ids) throws BasicException {
	        if (ids == null||ids.length==0)
	            return null;
	        Map<Long, T> rets = new HashMap<Long, T>();    
	        if (ids.length == 0)
	            return rets;
	        Map<String, Long[]> paramMap = new HashMap<String, Long[]>();
	        paramMap.put("ids", ids);
	        try {
	            List<T> objs = getSqlMapClientTemplate().queryForList(getNameSpace()+".getTsByIds",
	                paramMap);
	            for (T t : objs) {
	                if (t == null)
	                    continue;
	                rets.put((Long) (t.getUid()), t);
	            }
	        } catch (Exception ex) {
	            ex.printStackTrace();
	            throw new BasicException(ex);
	        }
	        return rets;
	    }

	

}
